<?php
/**
 * zouhao zouhao619@gmail.com
 */
class DisplacementModel extends Model{
	public function get_displacement_list(){
		$result=zmysql_query('select id,name,car_id,model_id from '.C('DB_PREFIX').'displacement order by sort asc');
		$data=array();
		while($row=zmysql_fetch_array($result)){
			$data[$row['car_id']][$row['model_id']][]=$row;
		}
		return $data;
	}
	public function find(){
		$info=parent::find();
		$info['displacement_project_list']=M('DisplacementProject')->where("displacement_id={$info['id']}")->select();
		$project_list=M('Project')->twoArrayField('id')->select();
		foreach ($info['displacement_project_list'] as $k=>$v){
			$info['displacement_project_list'][$k]['project']=$project_list[$v['project_id']];
		}
		return $info;
	}
}